package ${package.Controller};

import ${package.Entity}.${entity};
import ${package.Entity?remove_ending(".po")}.vo.Get${entity?remove_ending("PO")}ListVO;
import ${package.Entity?remove_ending(".po")}.dto.Save${entity?remove_ending("PO")}DTO;
import ${package.Entity?remove_ending(".po")}.dto.DeleteCommonDTO;
import ${package.Service}.${table.serviceName};
import ${package.Entity?remove_ending(".entity.po")}.common.vo.RespVO;
import io.swagger.annotations.Api;
import ${package.Entity?remove_ending(".entity.po")}.common.vo.FilteredParameter;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


<#if restControllerStyle>
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * ${table.comment} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Api(tags = "${table.comment}")
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Resource
    ${table.serviceName} ${table.serviceName?uncap_first};

    @ApiOperation(value = "查${table.comment!}列表")
    @GetMapping("get-list")
    public RespVO<List<Get${entity?remove_ending("PO")}ListVO>> get${entity?remove_ending("PO")}List(FilteredParameter dto) {
        return ${table.serviceName?uncap_first}.get${entity?remove_ending("PO")}List(dto);
    }

    @ApiOperation(value = "新增${table.comment}")
    @PostMapping("add")
    public RespVO<Object> add${entity?remove_ending("PO")}(@Valid @RequestBody Save${entity?remove_ending("PO")}DTO dto) {
        return ${table.serviceName?uncap_first}.add${entity?remove_ending("PO")}(dto);
    }

    @ApiOperation(value = "修改${table.comment}")
    @PostMapping("update")
    public RespVO<Object> update${entity?remove_ending("PO")}(@Valid @RequestBody Save${entity?remove_ending("PO")}DTO dto) {
        return ${table.serviceName?uncap_first}.update${entity?remove_ending("PO")}(dto);
    }

    @ApiOperation(value = "新增或修改${table.comment!}信息")
    @PostMapping("save")
    public RespVO<Object> save${entity?remove_ending("PO")}(@Valid @RequestBody Save${entity?remove_ending("PO")}DTO dto) {
        return ${table.serviceName?uncap_first}.save${entity?remove_ending("PO")}(dto);
    }

    @ApiOperation(value = "删除${table.comment}")
    @PostMapping("removes")
    public RespVO<Object> removes${entity?remove_ending("PO")}(@Valid @RequestBody DeleteCommonDTO dto) {
        return ${table.serviceName?uncap_first}.removes${entity?remove_ending("PO")}(dto);
    }
}
</#if>
